package Array;

import java.util.*;

/**
 * @auther wangchenghao
 * @date 2021/6/3
 * 只出现一次的数字
 **/
public class test5 {
    public int singleNumber(int[] nums) {
        HashMap<Integer, Boolean> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if (map.containsKey(nums[i])) {
                map.put(i, false);
            } else {
                map.put(i, true);
            }
        }
        int flag = 0;
        for (Integer key : map.keySet()) {
            System.out.print(key);
            System.out.print(map.get(key));
            if (map.get(key).equals(true)) {
                flag=key;
                break;
            }
        }
        return flag;

    }

}
